package com.fsquare.shipping.api.wrapper;

import java.math.BigDecimal;

import javax.servlet.http.HttpServletRequest;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;

import org.broadleafcommerce.core.order.fulfillment.domain.FulfillmentPriceBand;
import org.broadleafcommerce.core.web.api.wrapper.APIUnwrapper;
import org.broadleafcommerce.core.web.api.wrapper.APIWrapper;
import org.broadleafcommerce.core.web.api.wrapper.BaseWrapper;
import org.springframework.context.ApplicationContext;

@XmlRootElement(name = "fulfillmentPriceBandWrapper")
@XmlAccessorType(value = XmlAccessType.FIELD)
public class FulfillmentPriceBandWrapper extends BaseWrapper implements APIWrapper<FulfillmentPriceBand>, APIUnwrapper<FulfillmentPriceBand>{
	
	@XmlElement
	protected Long id;

	@XmlElement	    
	protected BigDecimal retailPriceMinimumAmount;
	    
	@XmlElement
	protected BandedPriceFulfillmentOptionWrapper option;

	@Override
	public void wrapDetails(FulfillmentPriceBand model, HttpServletRequest request) {
		this.id = model.getId();
//        if (model.getOption() != null) {
//            this.option = (BandedPriceFulfillmentOptionWrapper) context.getBean(BandedPriceFulfillmentOptionWrapper.class.getName());
//            this.option.wrapDetails(model.getOption(), request);
//        }
		
        this.retailPriceMinimumAmount = model.getRetailPriceMinimumAmount();
	}

	@Override
	public void wrapSummary(FulfillmentPriceBand model, HttpServletRequest request) {
		wrapDetails(model, request);
	}

	@Override
	public FulfillmentPriceBand unwrap(HttpServletRequest request, ApplicationContext context) {
		return null;
	}
	
}
